<?php

namespace app\common\model\mycurrency;

use addons\mycurrency\library\Common;
use think\Model;
use traits\model\SoftDelete;

class Pay extends Model
{

    //use SoftDelete;


    // 表名
    protected $name = 'mycurrency_pay';

    const PAY_TYPE_WECHAT = 1;//支付方式 = 微信支付
    const PAY_TYPE_ALIPAY = 2;//支付方式 = 支付宝支付

    const ORDER_TYPE_YUE = 1;//订单类型 = 用户余额充值订单

    const STATUS_CHAOSHI = -1;//支付状态 = 支付超时
    const STATUS_QUXIAO = -2;//支付状态 = 已取消
    const STATUS_DAIZHIFU = 1;//支付状态 = 待支付
    const STATUS_YIZHIFU = 2;//支付状态 = 已支付

    /**
     * 生成支付单单号
     * @return string
     */
    public static function createPayOrderSn()
    {
        $payOrderSn = date('YmdHis') . mt_rand(1000, 9999);
        $exists = self::where('ordersn', $payOrderSn)->value('id');
        if (!$exists) {
            return $payOrderSn;
        }
        return self::createPayOrderSn();
    }
}
